using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;
namespace Medianamik.Core.DAL.SubSonicDAL{
    /// <summary>
    /// Strongly-typed collection for the ManyToManyRelation class.
    /// </summary>
    [Serializable]
    public partial class ManyToManyRelationCollection : ReadOnlyList<ManyToManyRelation, ManyToManyRelationCollection>
    {        
        public ManyToManyRelationCollection() {}
    }
    /// <summary>
    /// This is  Read-only wrapper class for the vw_medianamik_ManyToManyRelation view.
    /// </summary>
    [Serializable]
    public partial class ManyToManyRelation : ReadOnlyRecord<ManyToManyRelation>, IReadOnlyRecord
    {
    
	    #region Default Settings
	    protected static void SetSQLProps() 
	    {
		    GetTableSchema();
	    }
	    #endregion
        #region Schema Accessor
	    public static TableSchema.Table Schema
        {
            get
            {
                if (BaseSchema == null)
                {
                    SetSQLProps();
                }
                return BaseSchema;
            }
        }
    	
        private static void GetTableSchema() 
        {
            if(!IsSchemaInitialized)
            {
                //Schema declaration
                TableSchema.Table schema = new TableSchema.Table("vw_medianamik_ManyToManyRelation", TableType.View, DataService.GetInstance("MedianamikProvider"));
                schema.Columns = new TableSchema.TableColumnCollection();
                schema.SchemaName = @"dbo";
                //columns
                
                TableSchema.TableColumn colvarForeignTypeId = new TableSchema.TableColumn(schema);
                colvarForeignTypeId.ColumnName = "ForeignTypeId";
                colvarForeignTypeId.DataType = DbType.Guid;
                colvarForeignTypeId.MaxLength = 0;
                colvarForeignTypeId.AutoIncrement = false;
                colvarForeignTypeId.IsNullable = false;
                colvarForeignTypeId.IsPrimaryKey = false;
                colvarForeignTypeId.IsForeignKey = false;
                colvarForeignTypeId.IsReadOnly = false;
                
                schema.Columns.Add(colvarForeignTypeId);
                
                TableSchema.TableColumn colvarForeignTypeIsManyToMany = new TableSchema.TableColumn(schema);
                colvarForeignTypeIsManyToMany.ColumnName = "ForeignTypeIsManyToMany";
                colvarForeignTypeIsManyToMany.DataType = DbType.Boolean;
                colvarForeignTypeIsManyToMany.MaxLength = 0;
                colvarForeignTypeIsManyToMany.AutoIncrement = false;
                colvarForeignTypeIsManyToMany.IsNullable = false;
                colvarForeignTypeIsManyToMany.IsPrimaryKey = false;
                colvarForeignTypeIsManyToMany.IsForeignKey = false;
                colvarForeignTypeIsManyToMany.IsReadOnly = false;
                
                schema.Columns.Add(colvarForeignTypeIsManyToMany);
                
                TableSchema.TableColumn colvarLeftPrimaryPropertyId = new TableSchema.TableColumn(schema);
                colvarLeftPrimaryPropertyId.ColumnName = "LeftPrimaryPropertyId";
                colvarLeftPrimaryPropertyId.DataType = DbType.Guid;
                colvarLeftPrimaryPropertyId.MaxLength = 0;
                colvarLeftPrimaryPropertyId.AutoIncrement = false;
                colvarLeftPrimaryPropertyId.IsNullable = false;
                colvarLeftPrimaryPropertyId.IsPrimaryKey = false;
                colvarLeftPrimaryPropertyId.IsForeignKey = false;
                colvarLeftPrimaryPropertyId.IsReadOnly = false;
                
                schema.Columns.Add(colvarLeftPrimaryPropertyId);
                
                TableSchema.TableColumn colvarLeftPrimaryTypeId = new TableSchema.TableColumn(schema);
                colvarLeftPrimaryTypeId.ColumnName = "LeftPrimaryTypeId";
                colvarLeftPrimaryTypeId.DataType = DbType.Guid;
                colvarLeftPrimaryTypeId.MaxLength = 0;
                colvarLeftPrimaryTypeId.AutoIncrement = false;
                colvarLeftPrimaryTypeId.IsNullable = false;
                colvarLeftPrimaryTypeId.IsPrimaryKey = false;
                colvarLeftPrimaryTypeId.IsForeignKey = false;
                colvarLeftPrimaryTypeId.IsReadOnly = false;
                
                schema.Columns.Add(colvarLeftPrimaryTypeId);
                
                TableSchema.TableColumn colvarRightPrimaryPropertyId = new TableSchema.TableColumn(schema);
                colvarRightPrimaryPropertyId.ColumnName = "RightPrimaryPropertyId";
                colvarRightPrimaryPropertyId.DataType = DbType.Guid;
                colvarRightPrimaryPropertyId.MaxLength = 0;
                colvarRightPrimaryPropertyId.AutoIncrement = false;
                colvarRightPrimaryPropertyId.IsNullable = false;
                colvarRightPrimaryPropertyId.IsPrimaryKey = false;
                colvarRightPrimaryPropertyId.IsForeignKey = false;
                colvarRightPrimaryPropertyId.IsReadOnly = false;
                
                schema.Columns.Add(colvarRightPrimaryPropertyId);
                
                TableSchema.TableColumn colvarRightPrimaryTypeId = new TableSchema.TableColumn(schema);
                colvarRightPrimaryTypeId.ColumnName = "RightPrimaryTypeId";
                colvarRightPrimaryTypeId.DataType = DbType.Guid;
                colvarRightPrimaryTypeId.MaxLength = 0;
                colvarRightPrimaryTypeId.AutoIncrement = false;
                colvarRightPrimaryTypeId.IsNullable = false;
                colvarRightPrimaryTypeId.IsPrimaryKey = false;
                colvarRightPrimaryTypeId.IsForeignKey = false;
                colvarRightPrimaryTypeId.IsReadOnly = false;
                
                schema.Columns.Add(colvarRightPrimaryTypeId);
                
                TableSchema.TableColumn colvarLeftPrimaryTypeName = new TableSchema.TableColumn(schema);
                colvarLeftPrimaryTypeName.ColumnName = "LeftPrimaryTypeName";
                colvarLeftPrimaryTypeName.DataType = DbType.String;
                colvarLeftPrimaryTypeName.MaxLength = 50;
                colvarLeftPrimaryTypeName.AutoIncrement = false;
                colvarLeftPrimaryTypeName.IsNullable = false;
                colvarLeftPrimaryTypeName.IsPrimaryKey = false;
                colvarLeftPrimaryTypeName.IsForeignKey = false;
                colvarLeftPrimaryTypeName.IsReadOnly = false;
                
                schema.Columns.Add(colvarLeftPrimaryTypeName);
                
                TableSchema.TableColumn colvarLeftPrimaryPropertyName = new TableSchema.TableColumn(schema);
                colvarLeftPrimaryPropertyName.ColumnName = "LeftPrimaryPropertyName";
                colvarLeftPrimaryPropertyName.DataType = DbType.String;
                colvarLeftPrimaryPropertyName.MaxLength = 50;
                colvarLeftPrimaryPropertyName.AutoIncrement = false;
                colvarLeftPrimaryPropertyName.IsNullable = false;
                colvarLeftPrimaryPropertyName.IsPrimaryKey = false;
                colvarLeftPrimaryPropertyName.IsForeignKey = false;
                colvarLeftPrimaryPropertyName.IsReadOnly = false;
                
                schema.Columns.Add(colvarLeftPrimaryPropertyName);
                
                TableSchema.TableColumn colvarLeftForeignPropertyName = new TableSchema.TableColumn(schema);
                colvarLeftForeignPropertyName.ColumnName = "LeftForeignPropertyName";
                colvarLeftForeignPropertyName.DataType = DbType.String;
                colvarLeftForeignPropertyName.MaxLength = 50;
                colvarLeftForeignPropertyName.AutoIncrement = false;
                colvarLeftForeignPropertyName.IsNullable = false;
                colvarLeftForeignPropertyName.IsPrimaryKey = false;
                colvarLeftForeignPropertyName.IsForeignKey = false;
                colvarLeftForeignPropertyName.IsReadOnly = false;
                
                schema.Columns.Add(colvarLeftForeignPropertyName);
                
                TableSchema.TableColumn colvarRightPrimaryTypeName = new TableSchema.TableColumn(schema);
                colvarRightPrimaryTypeName.ColumnName = "RightPrimaryTypeName";
                colvarRightPrimaryTypeName.DataType = DbType.String;
                colvarRightPrimaryTypeName.MaxLength = 50;
                colvarRightPrimaryTypeName.AutoIncrement = false;
                colvarRightPrimaryTypeName.IsNullable = false;
                colvarRightPrimaryTypeName.IsPrimaryKey = false;
                colvarRightPrimaryTypeName.IsForeignKey = false;
                colvarRightPrimaryTypeName.IsReadOnly = false;
                
                schema.Columns.Add(colvarRightPrimaryTypeName);
                
                TableSchema.TableColumn colvarRightPrimaryPropertyName = new TableSchema.TableColumn(schema);
                colvarRightPrimaryPropertyName.ColumnName = "RightPrimaryPropertyName";
                colvarRightPrimaryPropertyName.DataType = DbType.String;
                colvarRightPrimaryPropertyName.MaxLength = 50;
                colvarRightPrimaryPropertyName.AutoIncrement = false;
                colvarRightPrimaryPropertyName.IsNullable = false;
                colvarRightPrimaryPropertyName.IsPrimaryKey = false;
                colvarRightPrimaryPropertyName.IsForeignKey = false;
                colvarRightPrimaryPropertyName.IsReadOnly = false;
                
                schema.Columns.Add(colvarRightPrimaryPropertyName);
                
                TableSchema.TableColumn colvarRightForeignPropertyName = new TableSchema.TableColumn(schema);
                colvarRightForeignPropertyName.ColumnName = "RightForeignPropertyName";
                colvarRightForeignPropertyName.DataType = DbType.String;
                colvarRightForeignPropertyName.MaxLength = 50;
                colvarRightForeignPropertyName.AutoIncrement = false;
                colvarRightForeignPropertyName.IsNullable = false;
                colvarRightForeignPropertyName.IsPrimaryKey = false;
                colvarRightForeignPropertyName.IsForeignKey = false;
                colvarRightForeignPropertyName.IsReadOnly = false;
                
                schema.Columns.Add(colvarRightForeignPropertyName);
                
                TableSchema.TableColumn colvarLeftForeignPropertyId = new TableSchema.TableColumn(schema);
                colvarLeftForeignPropertyId.ColumnName = "LeftForeignPropertyId";
                colvarLeftForeignPropertyId.DataType = DbType.Guid;
                colvarLeftForeignPropertyId.MaxLength = 0;
                colvarLeftForeignPropertyId.AutoIncrement = false;
                colvarLeftForeignPropertyId.IsNullable = false;
                colvarLeftForeignPropertyId.IsPrimaryKey = false;
                colvarLeftForeignPropertyId.IsForeignKey = false;
                colvarLeftForeignPropertyId.IsReadOnly = false;
                
                schema.Columns.Add(colvarLeftForeignPropertyId);
                
                TableSchema.TableColumn colvarRightForeignPropertyId = new TableSchema.TableColumn(schema);
                colvarRightForeignPropertyId.ColumnName = "RightForeignPropertyId";
                colvarRightForeignPropertyId.DataType = DbType.Guid;
                colvarRightForeignPropertyId.MaxLength = 0;
                colvarRightForeignPropertyId.AutoIncrement = false;
                colvarRightForeignPropertyId.IsNullable = false;
                colvarRightForeignPropertyId.IsPrimaryKey = false;
                colvarRightForeignPropertyId.IsForeignKey = false;
                colvarRightForeignPropertyId.IsReadOnly = false;
                
                schema.Columns.Add(colvarRightForeignPropertyId);
                
                TableSchema.TableColumn colvarForeignTypeName = new TableSchema.TableColumn(schema);
                colvarForeignTypeName.ColumnName = "ForeignTypeName";
                colvarForeignTypeName.DataType = DbType.String;
                colvarForeignTypeName.MaxLength = 50;
                colvarForeignTypeName.AutoIncrement = false;
                colvarForeignTypeName.IsNullable = false;
                colvarForeignTypeName.IsPrimaryKey = false;
                colvarForeignTypeName.IsForeignKey = false;
                colvarForeignTypeName.IsReadOnly = false;
                
                schema.Columns.Add(colvarForeignTypeName);
                
                
                BaseSchema = schema;
                //add this schema to the provider
                //so we can query it later
                DataService.Providers["MedianamikProvider"].AddSchema("vw_medianamik_ManyToManyRelation",schema);
            }
        }
        #endregion
        
        #region Query Accessor
	    public static Query CreateQuery()
	    {
		    return new Query(Schema);
	    }
	    #endregion
	    
	    #region .ctors
	    public ManyToManyRelation()
	    {
            SetSQLProps();
            SetDefaults();
            MarkNew();
        }
        public ManyToManyRelation(bool useDatabaseDefaults)
	    {
		    SetSQLProps();
		    if(useDatabaseDefaults)
		    {
				ForceDefaults();
			}
			MarkNew();
	    }
	    
	    public ManyToManyRelation(object keyID)
	    {
		    SetSQLProps();
		    LoadByKey(keyID);
	    }
    	 
	    public ManyToManyRelation(string columnName, object columnValue)
        {
            SetSQLProps();
            LoadByParam(columnName,columnValue);
        }
        
	    #endregion
	    
	    #region Props
	    
          
        [XmlAttribute("ForeignTypeId")]
        [Bindable(true)]
        public Guid ForeignTypeId 
	    {
		    get
		    {
			    return GetColumnValue<Guid>("ForeignTypeId");
		    }
            set 
		    {
			    SetColumnValue("ForeignTypeId", value);
            }
        }
	      
        [XmlAttribute("ForeignTypeIsManyToMany")]
        [Bindable(true)]
        public bool ForeignTypeIsManyToMany 
	    {
		    get
		    {
			    return GetColumnValue<bool>("ForeignTypeIsManyToMany");
		    }
            set 
		    {
			    SetColumnValue("ForeignTypeIsManyToMany", value);
            }
        }
	      
        [XmlAttribute("LeftPrimaryPropertyId")]
        [Bindable(true)]
        public Guid LeftPrimaryPropertyId 
	    {
		    get
		    {
			    return GetColumnValue<Guid>("LeftPrimaryPropertyId");
		    }
            set 
		    {
			    SetColumnValue("LeftPrimaryPropertyId", value);
            }
        }
	      
        [XmlAttribute("LeftPrimaryTypeId")]
        [Bindable(true)]
        public Guid LeftPrimaryTypeId 
	    {
		    get
		    {
			    return GetColumnValue<Guid>("LeftPrimaryTypeId");
		    }
            set 
		    {
			    SetColumnValue("LeftPrimaryTypeId", value);
            }
        }
	      
        [XmlAttribute("RightPrimaryPropertyId")]
        [Bindable(true)]
        public Guid RightPrimaryPropertyId 
	    {
		    get
		    {
			    return GetColumnValue<Guid>("RightPrimaryPropertyId");
		    }
            set 
		    {
			    SetColumnValue("RightPrimaryPropertyId", value);
            }
        }
	      
        [XmlAttribute("RightPrimaryTypeId")]
        [Bindable(true)]
        public Guid RightPrimaryTypeId 
	    {
		    get
		    {
			    return GetColumnValue<Guid>("RightPrimaryTypeId");
		    }
            set 
		    {
			    SetColumnValue("RightPrimaryTypeId", value);
            }
        }
	      
        [XmlAttribute("LeftPrimaryTypeName")]
        [Bindable(true)]
        public string LeftPrimaryTypeName 
	    {
		    get
		    {
			    return GetColumnValue<string>("LeftPrimaryTypeName");
		    }
            set 
		    {
			    SetColumnValue("LeftPrimaryTypeName", value);
            }
        }
	      
        [XmlAttribute("LeftPrimaryPropertyName")]
        [Bindable(true)]
        public string LeftPrimaryPropertyName 
	    {
		    get
		    {
			    return GetColumnValue<string>("LeftPrimaryPropertyName");
		    }
            set 
		    {
			    SetColumnValue("LeftPrimaryPropertyName", value);
            }
        }
	      
        [XmlAttribute("LeftForeignPropertyName")]
        [Bindable(true)]
        public string LeftForeignPropertyName 
	    {
		    get
		    {
			    return GetColumnValue<string>("LeftForeignPropertyName");
		    }
            set 
		    {
			    SetColumnValue("LeftForeignPropertyName", value);
            }
        }
	      
        [XmlAttribute("RightPrimaryTypeName")]
        [Bindable(true)]
        public string RightPrimaryTypeName 
	    {
		    get
		    {
			    return GetColumnValue<string>("RightPrimaryTypeName");
		    }
            set 
		    {
			    SetColumnValue("RightPrimaryTypeName", value);
            }
        }
	      
        [XmlAttribute("RightPrimaryPropertyName")]
        [Bindable(true)]
        public string RightPrimaryPropertyName 
	    {
		    get
		    {
			    return GetColumnValue<string>("RightPrimaryPropertyName");
		    }
            set 
		    {
			    SetColumnValue("RightPrimaryPropertyName", value);
            }
        }
	      
        [XmlAttribute("RightForeignPropertyName")]
        [Bindable(true)]
        public string RightForeignPropertyName 
	    {
		    get
		    {
			    return GetColumnValue<string>("RightForeignPropertyName");
		    }
            set 
		    {
			    SetColumnValue("RightForeignPropertyName", value);
            }
        }
	      
        [XmlAttribute("LeftForeignPropertyId")]
        [Bindable(true)]
        public Guid LeftForeignPropertyId 
	    {
		    get
		    {
			    return GetColumnValue<Guid>("LeftForeignPropertyId");
		    }
            set 
		    {
			    SetColumnValue("LeftForeignPropertyId", value);
            }
        }
	      
        [XmlAttribute("RightForeignPropertyId")]
        [Bindable(true)]
        public Guid RightForeignPropertyId 
	    {
		    get
		    {
			    return GetColumnValue<Guid>("RightForeignPropertyId");
		    }
            set 
		    {
			    SetColumnValue("RightForeignPropertyId", value);
            }
        }
	      
        [XmlAttribute("ForeignTypeName")]
        [Bindable(true)]
        public string ForeignTypeName 
	    {
		    get
		    {
			    return GetColumnValue<string>("ForeignTypeName");
		    }
            set 
		    {
			    SetColumnValue("ForeignTypeName", value);
            }
        }
	    
	    #endregion
    
	    #region Columns Struct
	    public struct Columns
	    {
		    
		    
            public static string ForeignTypeId = @"ForeignTypeId";
            
            public static string ForeignTypeIsManyToMany = @"ForeignTypeIsManyToMany";
            
            public static string LeftPrimaryPropertyId = @"LeftPrimaryPropertyId";
            
            public static string LeftPrimaryTypeId = @"LeftPrimaryTypeId";
            
            public static string RightPrimaryPropertyId = @"RightPrimaryPropertyId";
            
            public static string RightPrimaryTypeId = @"RightPrimaryTypeId";
            
            public static string LeftPrimaryTypeName = @"LeftPrimaryTypeName";
            
            public static string LeftPrimaryPropertyName = @"LeftPrimaryPropertyName";
            
            public static string LeftForeignPropertyName = @"LeftForeignPropertyName";
            
            public static string RightPrimaryTypeName = @"RightPrimaryTypeName";
            
            public static string RightPrimaryPropertyName = @"RightPrimaryPropertyName";
            
            public static string RightForeignPropertyName = @"RightForeignPropertyName";
            
            public static string LeftForeignPropertyId = @"LeftForeignPropertyId";
            
            public static string RightForeignPropertyId = @"RightForeignPropertyId";
            
            public static string ForeignTypeName = @"ForeignTypeName";
            
	    }
	    #endregion
	    
	    
	    #region IAbstractRecord Members
        public new CT GetColumnValue<CT>(string columnName) {
            return base.GetColumnValue<CT>(columnName);
        }
        public object GetColumnValue(string columnName) {
            return base.GetColumnValue<object>(columnName);
        }
        #endregion
	    
    }
}
